package org.jivesoftware.smack;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.xmlpull.v1.XmlPullParser;

public final class SmackConfiguration
{
  private static final String SMACK_VERSION = "3.1.0";
  private static Vector<String> defaultMechs;
  private static int keepAliveInterval;
  private static int packetReplyTimeout = 5000;

  // ERROR //
  static
  {
    // Byte code:
    //   0: sipush 5000
    //   3: putstatic 20	org/jivesoftware/smack/SmackConfiguration:packetReplyTimeout	I
    //   6: sipush 30000
    //   9: putstatic 22	org/jivesoftware/smack/SmackConfiguration:keepAliveInterval	I
    //   12: new 24	java/util/Vector
    //   15: dup
    //   16: invokespecial 27	java/util/Vector:<init>	()V
    //   19: putstatic 29	org/jivesoftware/smack/SmackConfiguration:defaultMechs	Ljava/util/Vector;
    //   22: invokestatic 33	org/jivesoftware/smack/SmackConfiguration:getClassLoaders	()[Ljava/lang/ClassLoader;
    //   25: astore_1
    //   26: aload_1
    //   27: arraylength
    //   28: istore_2
    //   29: iconst_0
    //   30: istore_3
    //   31: goto +280 -> 311
    //   34: aload_1
    //   35: iload_3
    //   36: aaload
    //   37: ldc 35
    //   39: invokevirtual 41	java/lang/ClassLoader:getResources	(Ljava/lang/String;)Ljava/util/Enumeration;
    //   42: astore 4
    //   44: aload 4
    //   46: invokeinterface 47 1 0
    //   51: ifne +9 -> 60
    //   54: iinc 3 1
    //   57: goto +254 -> 311
    //   60: aload 4
    //   62: invokeinterface 51 1 0
    //   67: checkcast 53	java/net/URL
    //   70: astore 5
    //   72: aconst_null
    //   73: astore 6
    //   75: aload 5
    //   77: invokevirtual 57	java/net/URL:openStream	()Ljava/io/InputStream;
    //   80: astore 6
    //   82: invokestatic 63	org/xmlpull/v1/XmlPullParserFactory:newInstance	()Lorg/xmlpull/v1/XmlPullParserFactory;
    //   85: invokevirtual 67	org/xmlpull/v1/XmlPullParserFactory:newPullParser	()Lorg/xmlpull/v1/XmlPullParser;
    //   88: astore 11
    //   90: aload 11
    //   92: ldc 69
    //   94: iconst_1
    //   95: invokeinterface 75 3 0
    //   100: aload 11
    //   102: aload 6
    //   104: ldc 77
    //   106: invokeinterface 81 3 0
    //   111: aload 11
    //   113: invokeinterface 85 1 0
    //   118: istore 12
    //   120: iload 12
    //   122: iconst_2
    //   123: if_icmpne +23 -> 146
    //   126: aload 11
    //   128: invokeinterface 89 1 0
    //   133: ldc 91
    //   135: invokevirtual 97	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   138: ifeq +40 -> 178
    //   141: aload 11
    //   143: invokestatic 101	org/jivesoftware/smack/SmackConfiguration:parseClassToLoad	(Lorg/xmlpull/v1/XmlPullParser;)V
    //   146: aload 11
    //   148: invokeinterface 104 1 0
    //   153: istore 13
    //   155: iload 13
    //   157: istore 12
    //   159: iload 12
    //   161: iconst_1
    //   162: if_icmpne -42 -> 120
    //   165: aload 6
    //   167: invokevirtual 109	java/io/InputStream:close	()V
    //   170: goto -126 -> 44
    //   173: astore 14
    //   175: goto -131 -> 44
    //   178: aload 11
    //   180: invokeinterface 89 1 0
    //   185: ldc 110
    //   187: invokevirtual 97	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   190: ifeq +37 -> 227
    //   193: aload 11
    //   195: getstatic 20	org/jivesoftware/smack/SmackConfiguration:packetReplyTimeout	I
    //   198: invokestatic 114	org/jivesoftware/smack/SmackConfiguration:parseIntProperty	(Lorg/xmlpull/v1/XmlPullParser;I)I
    //   201: putstatic 20	org/jivesoftware/smack/SmackConfiguration:packetReplyTimeout	I
    //   204: goto -58 -> 146
    //   207: astore 9
    //   209: aload 9
    //   211: invokevirtual 117	java/lang/Exception:printStackTrace	()V
    //   214: aload 6
    //   216: invokevirtual 109	java/io/InputStream:close	()V
    //   219: goto -175 -> 44
    //   222: astore 10
    //   224: goto -180 -> 44
    //   227: aload 11
    //   229: invokeinterface 89 1 0
    //   234: ldc 118
    //   236: invokevirtual 97	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   239: ifeq +35 -> 274
    //   242: aload 11
    //   244: getstatic 22	org/jivesoftware/smack/SmackConfiguration:keepAliveInterval	I
    //   247: invokestatic 114	org/jivesoftware/smack/SmackConfiguration:parseIntProperty	(Lorg/xmlpull/v1/XmlPullParser;I)I
    //   250: putstatic 22	org/jivesoftware/smack/SmackConfiguration:keepAliveInterval	I
    //   253: goto -107 -> 146
    //   256: astore 7
    //   258: aload 6
    //   260: invokevirtual 109	java/io/InputStream:close	()V
    //   263: aload 7
    //   265: athrow
    //   266: astore_0
    //   267: aload_0
    //   268: invokevirtual 117	java/lang/Exception:printStackTrace	()V
    //   271: goto +45 -> 316
    //   274: aload 11
    //   276: invokeinterface 89 1 0
    //   281: ldc 120
    //   283: invokevirtual 97	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   286: ifeq -140 -> 146
    //   289: getstatic 29	org/jivesoftware/smack/SmackConfiguration:defaultMechs	Ljava/util/Vector;
    //   292: aload 11
    //   294: invokeinterface 123 1 0
    //   299: invokevirtual 126	java/util/Vector:add	(Ljava/lang/Object;)Z
    //   302: pop
    //   303: goto -157 -> 146
    //   306: astore 8
    //   308: goto -45 -> 263
    //   311: iload_3
    //   312: iload_2
    //   313: if_icmplt -279 -> 34
    //   316: return
    //
    // Exception table:
    //   from	to	target	type
    //   165	170	173	java/lang/Exception
    //   75	155	207	java/lang/Exception
    //   178	204	207	java/lang/Exception
    //   227	253	207	java/lang/Exception
    //   274	303	207	java/lang/Exception
    //   214	219	222	java/lang/Exception
    //   75	155	256	finally
    //   178	204	256	finally
    //   209	214	256	finally
    //   227	253	256	finally
    //   274	303	256	finally
    //   22	72	266	java/lang/Exception
    //   263	266	266	java/lang/Exception
    //   258	263	306	java/lang/Exception
  }

  public static void addSaslMech(String paramString)
  {
    if (!(defaultMechs.contains(paramString)))
      defaultMechs.add(paramString);
  }

  public static void addSaslMechs(Collection<String> paramCollection)
  {
    Iterator localIterator = paramCollection.iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
        return;
      addSaslMech((String)localIterator.next());
    }
  }

  private static ClassLoader[] getClassLoaders()
  {
    ClassLoader[] arrayOfClassLoader = new ClassLoader[2];
    arrayOfClassLoader[0] = SmackConfiguration.class.getClassLoader();
    arrayOfClassLoader[1] = Thread.currentThread().getContextClassLoader();
    ArrayList localArrayList = new ArrayList();
    int i = arrayOfClassLoader.length;
    int j = 0;
    while (true)
    {
      if (j >= i)
        return ((ClassLoader[])localArrayList.toArray(new ClassLoader[localArrayList.size()]));
      ClassLoader localClassLoader = arrayOfClassLoader[j];
      if (localClassLoader != null)
        localArrayList.add(localClassLoader);
      ++j;
    }
  }

  public static int getKeepAliveInterval()
  {
    return keepAliveInterval;
  }

  public static int getPacketReplyTimeout()
  {
    if (packetReplyTimeout <= 0)
      packetReplyTimeout = 5000;
    return packetReplyTimeout;
  }

  public static List<String> getSaslMechs()
  {
    return defaultMechs;
  }

  public static String getVersion()
  {
    return "3.1.0";
  }

  private static void parseClassToLoad(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    String str = paramXmlPullParser.nextText();
    try
    {
      Class.forName(str);
      return;
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      System.err.println("Error! A startup class specified in smack-config.xml could not be loaded: " + str);
    }
  }

  private static int parseIntProperty(XmlPullParser paramXmlPullParser, int paramInt)
    throws Exception
  {
    int i;
    int j;
    try
    {
      j = Integer.parseInt(paramXmlPullParser.nextText());
      i = j;
      return i;
    }
    catch (NumberFormatException localNumberFormatException)
    {
      localNumberFormatException.printStackTrace();
      i = paramInt;
    }
  }

  public static void removeSaslMech(String paramString)
  {
    if (defaultMechs.contains(paramString))
      defaultMechs.remove(paramString);
  }

  public static void removeSaslMechs(Collection<String> paramCollection)
  {
    Iterator localIterator = paramCollection.iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
        return;
      removeSaslMech((String)localIterator.next());
    }
  }

  public static void setKeepAliveInterval(int paramInt)
  {
    keepAliveInterval = paramInt;
  }

  public static void setPacketReplyTimeout(int paramInt)
  {
    if (paramInt <= 0)
      throw new IllegalArgumentException();
    packetReplyTimeout = paramInt;
  }
}